-- Leafy Glade
-- save Sarina

function autoexec()
  if (get_progress(P_GIRL) == 1) then
    set_ent_id(2, SARINA)
   
   else
    set_ent_active(0, 0)
    set_ent_active(1, 0)
    set_ent_active(2, 0)


  end     
return
end

function refresh()
  return
end

function postexec() 
  if (get_progress(P_GIRL) == 1) then 
    LOC_fight()
  else
  --do nothing
  end
return

end


function zone_handler(zn)
  if (zn == 1) then
    change_map("land","glade2_exit");

  elseif (zn == 2) then
    change_map("land","glade2_exit", 1, 1);

  elseif (zn == 3) then 
    if (get_progress(P_GIRL) == 2) then
      door_in("hut_in")
    else  
      bubble(HERO1,"It's Locked.");
    end

  elseif (zn == 4) then  
    door_out("hut_out")

  elseif (zn == 5) then  
    touch_fire(get_pidx(0));

  elseif (zn == 6) then
    bubble(HERO1,"Hmm, my mom has the same painting. Sensar's house has one as well.");

  elseif (zn == 7) then
    thought(HERO1,"Hmm I better not go through Madam Marigold's stuff when she's looking. Not that I would want too.");

  elseif (zn == 8) then
   if (get_progress(P_GIRL) == 3) then
     thought(HERO1,"Hmm maybe I can risk a quick glance.");
     thought(HERO1,"... The first piece has been found. The heir has been asked to retrieve it...");
     thought(HERO1,"Whatever that means.");
    end
end
           


end

function LOC_fight() 
  set_autoparty(1)
  set_vfollow(1)
   
    bubble(2, "AHHH!");
    bubble(HERO1, "That does not sound good.");
    bubble(2, "Don't hurt me!");
    set_ent_speed(HERO1, 5)
    move_entity(HERO1, "run_to")
    wait_for_entity(HERO1, 0)
    set_ent_facing(HERO1, FACE_RIGHT)
    set_ent_speed(HERO1, 4)
    bubble(0, "Quiet girl or we will make things difficult for you.");
    bubble(HERO1, "Let her go!");
    bubble(0, "Not on my watch!");
    bubble(1, "I bet this one's FATHER will pay a hefty ransom.");
    bubble(HERO1, "Let's settle this.");
    bubble(2, "I can't watch.");
    drawmap()
    screen_dump()
    set_run(0)
    combat(0)
    set_run(1)
    if (get_alldead() == 1) then
      return
    end
    set_progress(P_GIRL, 2)
    refresh()
    set_ent_active(0, 0)
    set_ent_active(1, 0)
    drawmap()
    screen_dump() 
    set_ent_facing(2, FACE_LEFT)
    bubble(2, "How can I ever repay you? You coming an saving me... me being an Akanthosian in all...");
    bubble(HERO1, "It was nothing.", "Why were you out here anyway?");
    bubble(2, "I thought I would try my hand at an adventure and then as you saw, I landed myself in trouble.");
    bubble(2, "I am in your debt. Thank you.");
    bubble(HERO1, "Its ok.");
    bubble(2, "I better get going.");
    move_entity(2, "girl_walk");
    wait_for_entity(HERO1, 2)
    set_ent_active(2, 0)
 

end
 
-- 
function entity_handler(en)
  if (en == 0) then

  elseif (en == 3) then 
  if (get_progress(P_GIRL) == 2) then 
    bubble(HERO1, "Madam Marigold did you see it? A girl was just attacked outside your front door. I just fought them off.");
    bubble(en, "No sonny I didn't.");
    bubble(HERO1, "Um...");
    bubble(en, "Well you know I am getting on in age now $0. Who was it anyways?"); 
    bubble(HERO1, "It was the Governor's daughter, Sarina.");
    msg("Madam Marigold mutters to herself", 255, 0)
    bubble(en, "I thought that was her...");
    bubble(HERO1, "What was that?"); 
    bubble(en, "Nothing my dear.  Just next time don't go get yourself killed for a Akanthosian.");
    bubble(en, "How's your mother gettin along these days anyways?");
    bubble(HERO1, "Buisness is good so its been alright.  My mother wanted to send you a message. Here you go.");
    bubble(en, "I see the seal is still on it.  You would make your father proud.");
    set_ftile("table", 312) --set scroll on table
    bubble(en, "Ooh! That is excellent news... The plan is coming along...");   
    bubble(HERO1, "What plan? Is this about King Amalric?");
    bubble(en, "Never you mind boy.");
    bubble(en, "In time all will be told."); 
    thought(HERO1, "I hate it when they say that.");
    bubble(en, "Well give your mother my thanks and tell her I will be calling on her shortly.");
    set_progress(P_GIRL, 3) 
   else
    bubble(en, "Give your mother my thanks and tell her I will be calling on her shortly.");
   end

  end
end
